<template>
  <div class="filter-item">
    <Select v-model="hospitalId" clearable filterable style="width:200px" placeholder="药店名称">
        <Option v-for="item in storeList" :value="item.id" :key="item.id">{{ item.orgName }}</Option>
    </Select>
  </div>
</template>

<script>
import api from "@/api/commonApi";
export default {
  model: {
    prop: 'hospitalId',
    event: 'change'
  },
  props: {
    hospitalId: [String, Number]
  },
  data() {
    return {
      storeList: []
    }
  },
  mounted() {
    this.pharmacyInfo();
  },
  methods: {
    pharmacyInfo() {
      this.$axios.post(api.mechanismregList, {pageNo: 1, pageSize: 9999, hospitalType: 2}).then(res => {
          if (res.data.code === 1) {
              this.storeList = res.data.object.records;
          }
      });
    },
  },
  watch: {
    hospitalId(n) {
      this.$emit('change', n);
    }
  }
}
</script>

<style scoped>
  .filter-item {
    display: flex;
    align-items: center;
  }
</style>